<template>
  <div class="xiugaigoumaihaoma">
    <el-dialog title="修改购买号码" :visible.sync="showchangenum" width="500px">
    	<div style="display:flex;align-items: center;">
    		<el-radio v-model="choosetype" :label="1">修改号码：</el-radio>
    		<el-input v-model="change_input" size="small" type="number" oninput="if(value.length>11){value=value.slice(0,11)}" style="width:300px" placeholder="请输入电话"></el-input>
    	</div>
    	<div style="display:flex;margin-top: 20px;margin-bottom: 20px;">
    		<el-radio v-model="choosetype" :label="2">使用随机号</el-radio>
    	</div>
    	<div style="text-align:center">
    		<el-button type="primary" @click="upchange">保存并重提</el-button>
    	</div>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    name: "xiugaigoumaihaoma",
    data() {
      return {
        choosetype:"",
        change_input:"",
        change_num_id:"",
        showchangenum:false
      }
    },
    created() {

    },
    mounted() {

    },
    methods: {
      upchange(){
      	if(this.choosetype==1){
      		var plan_mobile = this.change_input
      	}else{
      		var plan_mobile = 0
      	}
      	this.showchangenum = false
      	axios.post("/api/plan-market/plan-mobile/update", {
      		list:[{
      			id:this.change_num_id,
      			type:this.choosetype,
      			plan_mobile:plan_mobile,
      		}]
      	})
      	.then(response => {

      		if (response.data.msg.code == 0) {
      			if(response.data.data.error.length==0){
      				this.$message({
      				message: "修改成功",
      					type: "success"
      				});
      				this.getlist();
      			}else{
      				for(var x=0;x<response.data.data.error.length;x++){
      					alert(response.data.data.error[x])
      				}

      			}
      		} else {
      			this.$message.error(response.data.msg.info);
      		}
      	});
      },
    }
  }
</script>

<style lang="scss" scoped>
  .xiugaigoumaihaoma {

  }
</style>
